package xyz.xtt.user.client;

import java.util.Collection;
import java.util.List;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.common.response.ApiResult;
import xyz.xtt.pay.client.response.TblPayOrderDto;
import xyz.xtt.user.api.dto.TblUserFundRecordDto;
import xyz.xtt.user.api.dto.UpdateFundSettledRequest;
import xyz.xtt.user.client.request.UserRegRequest;
import xyz.xtt.user.client.response.UserInfoResponse;
import xyz.xtt.user.client.response.UserRegResponse;

@Slf4j
@Component
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
	@Override
	public UserClient create(Throwable throwable) {
		return new UserClient() {

			@Override
			public ApiResult<UserInfoResponse> info(Long appUid) {
				log.info("info FallbackFactory goodsId: {}", appUid);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<List<UserInfoResponse>> batchInfo(Collection<Long> appUids) {
				log.info("batchInfo FallbackFactory goodsId: {}", JSONUtil.toJsonStr(appUids));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<UserInfoResponse> infoWithPhone(String phone) {
				log.info("infoWithPhone FallbackFactory phone: {}", JSONUtil.toJsonStr(phone));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<UserRegResponse> register(UserRegRequest userRegRequest) {
				log.info("register FallbackFactory phone: {}", JSONUtil.toJsonStr(userRegRequest));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> checkAuth(String uid, Long authCheckFrequency) {
				log.info("infoWithPhone FallbackFactory uid:{},authCheckFrequency:{}", uid, authCheckFrequency);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<List<TblUserFundRecordDto>> getNeedSettleRecords(Integer maxCount, Long lastId) {
				log.info("infoWithPhone FallbackFactory maxCount:{},lastId:{}", maxCount, lastId);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> updateFundSettled(UpdateFundSettledRequest request) {
				log.info("updateFundSettled FallbackFactory request:{}", JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> handleOrderPaySuccess(TblPayOrderDto payOrderDto) {
				log.info("handleOrderPaySuccess FallbackFactory request:{}", JSONUtil.toJsonStr(payOrderDto));
				return ApiResult.failure();
			}

		};
	}
}
